package com.jxj.study.util;

import com.jxj.study.domian.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

//https://blog.csdn.net/u012373815/article/details/78956225
public class RunnableTask implements Runnable{
    private final Logger logger = LoggerFactory.getLogger(getClass());

    private final List<String> list;

    private String name;

    public void setName(String name){
        this.name = name;
    }
    public RunnableTask(List<String> list){
        this.list = list;
    }
 
    @Override
    public void run(){
        User user = new User();
        synchronized (Object.class){
            try {
                for (String s : list) {
                    Thread.currentThread().setName(name);
                    System.out.println(Thread.currentThread().getName() + " ----------异步：>" + s);
                    user.wait(200);
                }
            }catch (Exception ex){
                ex.printStackTrace();
            }
        }
    }
}